#pragma once

#include <memory>
#include <vector>
#include "instructions/base/instructions.h"
#include "instructions/base/bytecode_reader.h"
#include "rtda/frame.h"

namespace jvm {
namespace instructions {

// Unconditional branch
class GOTO : public BranchInstruction {
public:
    void execute(std::shared_ptr<rtda::Frame> frame) override;
};

// Table switch instruction
class TABLE_SWITCH : public Instruction {
private:
    int32_t _defaultOffset;
    int32_t _low;
    int32_t _high;
    std::vector<int32_t> _jumpOffsets;

public:
    void fetchOperands(std::shared_ptr<BytecodeReader> reader) override;
    void execute(std::shared_ptr<rtda::Frame> frame) override;
};

// Lookup switch instruction
class LOOKUP_SWITCH : public Instruction {
private:
    int32_t _defaultOffset;
    int32_t _npairs;
    std::vector<int32_t> _matchOffsets;

public:
    void fetchOperands(std::shared_ptr<BytecodeReader> reader) override;
    void execute(std::shared_ptr<rtda::Frame> frame) override;
};

} // namespace instructions
} // namespace jvm